<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

    <h:body>
        #{kalenderPM.init()}
        <ui:composition template="template.xhtml">
            <ui:define name="content">

                <div id="Event">
                    <h:form id="addEventForm">
                        <h:panelGrid columns="2" rendered="true">

                            <h:outputLabel for="titel">Titel:</h:outputLabel>

                            <h:inputText id="titel" value="#{kalenderPM.titel}" title="Titel"/>

                            <h:outputLabel for="description">Beschreibung:</h:outputLabel>

                            <h:inputTextarea style="resize: none;" cols="25" rows="2" id="description" value="#{kalenderPM.description}" title="Beschreibung" />                       

                            <h:outputLabel for="startTime" >Beginn(dd.MM.yyyy HH:mm):</h:outputLabel>

                            <h:inputText id="startTime" value="#{kalenderPM.startTime}" 
                                         size="20" required="true"
                                         label="startTime" >					
                                <f:convertDateTime type="both" pattern="dd.MM.yyyy HH:mm" timeZone="GMT+1" timeStyle="short" locale="de" dateStyle="short "/>
                            </h:inputText>

                            <h:outputLabel for="endTime" >Ende(dd.MM.yyyy HH:mm):</h:outputLabel>

                            <h:inputText id="endTime" value="#{kalenderPM.endTime}" 
                                         size="20" required="true"
                                         label="endTime" >					
                                <f:convertDateTime type="both" pattern="dd.MM.yyyy HH:mm" timeZone="GMT+1" timeStyle="short" locale="de" dateStyle="short" />
                            </h:inputText>                            

                            <h:commandButton value="Hinzufügen" action="#{kalenderPM.addEvent}"/>

                        </h:panelGrid>
                    </h:form>
                </div>

                
                <div id="kalender">
                    <table id="kalenderTable" class="order-table">
                        <tr>
                            <td></td>
                            <ui:repeat var ="day" value="#{kalenderPM.dayArray}" varStatus="status">

                                <td class="kalender_table_head">
                                    #{day}
                                </td>
                            </ui:repeat>

                        </tr>
                        <ui:repeat var="o" value="#{kalenderPM.getkalenderArray()}" varStatus="status">
                            <div id="day_evtl">
                                <tr id="order-table-even-row">

                                    <ui:repeat var="p" value="#{o}" varStatus="status2">
                                        <td id="zelle">

                                            <ui:repeat var="q" value="#{p}" varStatus="status3">
                                                <h:outputLabel value="#{q.startDate.getHours()}:00" rendered="#{q.titel == 'test666'}" /> 
      
                                                 <ui:fragment rendered="#{q.titel != 'test666'}" >     
                                                    <ui:fragment rendered="#{kalenderPM.isActive(q.parent.user)}">
                                                        <div id="eintrag" class="#{kalenderPM.findUserClass(q.parent.user)}" title="#{q.description}"
                                                             onclick="window.open('bearbeiten.xhtml?id=#{q.id}', 'Neuen Eintrag hinzufügen','width=530, height=298')" >
                                                         #{q.titel}
                                                    </div>
                                                    </ui:fragment>
                                                </ui:fragment>
                                            </ui:repeat>

                                        </td>
                                    </ui:repeat>
                                </tr>
                            </div>
                        </ui:repeat>
                    </table>
                </div>   



            </ui:define>
        </ui:composition>
    </h:body>
</html>
